package com.learning.level3;

/**
 * @author adolphw
 *
 * 可重入锁
 * 外部方法得到锁，内部方法无需再进行获取
 *
 * LockSupport 线程工具类 阻塞和唤醒线程
 */
public class ReEnterLockDemo {
    static Object objectA = new Object();

    public static void main(String[] args) {
        m1();
    }

    public static void m1() {
        new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "\t"+"-----------外层调用");
            synchronized ((objectA)) {
                System.out.println(Thread.currentThread().getName() + "\t"+"-----------内层调用");
                m2();
            }
        }, "t1").start();
    }

    public static void m2() {
        System.out.println(Thread.currentThread().getName() + "\t"+"-----------wai层调用");
    }
}
